/**
 * @format
 * @Author: TC
 * @Date: 2021-11-24 13:54:28
 * @Last Modified by: TC
 * @Last Modified time: 2023-03-25 21:59:53
 */

import { Collider2D } from "cc";
import { mCollideConst } from "../Const/ColldeConst";

//工具类
export namespace nsColliedUtil {
    export function getCollideGroup(group: number): mCollideConst.COLLIDE_GROUP {
        switch (group) {
            case 1 << 0:
                return mCollideConst.COLLIDE_GROUP.DEFAULT;
            case 1 << 1:
                return mCollideConst.COLLIDE_GROUP.MAP;
            case 1 << 2:
                return mCollideConst.COLLIDE_GROUP.HERO;
        }
    }

    export function isHero(collider: Collider2D): boolean {
        let group = this.getCollideGroup(collider.group);
        return group == mCollideConst.COLLIDE_GROUP.HERO;
    }

    export function isMap(collider: Collider2D): boolean {
        let group = this.getCollideGroup(collider.group);
        return group == mCollideConst.COLLIDE_GROUP.MAP;
    }
}
